<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<title>Document</title>
	</head>

	<body>
		<div>
			目前所在：<span id="result"></span>
		</div>
		<script src="./js/1.js" type="text/javascript"></script>
		<script type="text/javascript" src="./js/2.js"></script>
		<script>
			var test = (function() {
				var onSuccess = function(geoipResponse) {
					console.log(geoipResponse);

					if (!geoipResponse.country.iso_code) {
						return;
					}
					var code = geoipResponse.country.iso_code.toLowerCase();
					document.getElementById('result').innerHTML = code;
					uni.postMessage({
						data: {
							code: code,
						}
					})
				};
				var onError = function(error) {};
				return function() {
					geoip2.country(onSuccess, onError);
				};
			}());
			test();
		</script>
	</body>

</html>